﻿using MediatR;
using System.CJL.API.Application.Command.ProcessCommand;
using System.CJL.Infrstructre.Interface;

namespace System.CJL.API.Application.CommandHanlder.ProcessCommandHanler
{
    /// <summary>
    /// 删除
    /// </summary>
    public class ProcessDeleteCommandHandler : IRequestHandler<ProcessDeleteCommand, int>
    {
        IProcessRepository _repository;
        public ProcessDeleteCommandHandler(IProcessRepository repository)
        {
            _repository=repository;
        }

        public async Task<int> Handle(ProcessDeleteCommand request, CancellationToken cancellationToken)
        {
            var arr = await _repository.GetMondel(request.id);
            arr.IsDelete = true;
            arr.DelectTime = DateTime.Now.ToUniversalTime();
            return await _repository.UpdateAsync(arr);
        }
    }
}
